package com.laker.autotest.desktop;

import javax.swing.*;
import java.awt.*;

public class EventListModel {
    private final JTextArea textArea;

    public EventListModel(JTextArea textArea) {
        this.textArea = textArea;
    }

    public void addElement(String element) {
        SwingUtilities.invokeLater(() -> {
            textArea.append(element + "\n");
            textArea.setCaretPosition(textArea.getDocument().getLength());
        });
    }

    public void clearEvents() {
        SwingUtilities.invokeLater(() -> {
            textArea.setText("");
        });
    }

    public void clear() {
        clearEvents();
    }

    public JTextArea getTextArea() {
        return textArea;
    }
}
